# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=patsy
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.5.1
pkgrel=2
pkgdesc="A Python package for describing statistical models and for building design matrices (mingw-w64)"
arch=('any')
url="https://github.com/pydata/patsy"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-numpy"
             "${MINGW_PACKAGE_PREFIX}-python3-numpy"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
source=("https://pypi.python.org/packages/source/p/patsy/${_realname}-${pkgver}.tar.gz")
sha256sums=('f115cec4201e1465cd58b9866b0b0e7b941caafec129869057405bfe5b5e3991')

prepare() {
  cd "${srcdir}"
  cp -r ${_realname}-${pkgver} python2-${_realname}-${pkgver}
  cp -r ${_realname}-${pkgver} python3-${_realname}-${pkgver}
}

package_python3-patsy() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3-numpy")
  optdepends=("${MINGW_PACKAGE_PREFIX}-python3-nose: needed for integrated test suite"
              "${MINGW_PACKAGE_PREFIX}-python3-scipy: needed for spline-related functions")

  cd ${srcdir}/python3-${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root "${pkgdir}" --optimize=1

  install -Dm644 "${srcdir}/python3-${_realname}-${pkgver}/LICENSE.txt" \
  "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-patsy() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2-numpy")
  optdepends=("${MINGW_PACKAGE_PREFIX}-python2-nose: needed for integrated test suite"
              "${MINGW_PACKAGE_PREFIX}-python2-scipy: needed for spline-related functions")

  cd ${srcdir}/python2-${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root "${pkgdir}" --optimize=1

  install -Dm644 "${srcdir}/python3-${_realname}-${pkgver}/LICENSE.txt" \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-patsy() {
  package_python2-patsy
}

package_mingw-w64-i686-python3-patsy() {
  package_python3-patsy
}

package_mingw-w64-x86_64-python2-patsy() {
  package_python2-patsy
}

package_mingw-w64-x86_64-python3-patsy() {
  package_python3-patsy
}
